#include <climits>

class Solution {
  public:
    double myPow(double x, int n) {
        if (n >= 0)
            return unsigned_pow(x, n);
        else
            return 1 / unsigned_pow(x, -n);
    }

    double unsigned_pow(double x, unsigned n) {
        if (n == 0) return 1;
        if (n == 1) return x;
        double result = unsigned_pow(x, n / 2);
        result *= result;
        if (n % 2 == 1) result *= x;
        return result;
    }
};

int main() {
    Solution s;
    s.myPow(1, INT_MIN);
}
